package cn.bxshey.resourceSharing.entity;

import lombok.Data;

/**
 * @作者：不想说话而已
 * @Date：2023/12/16 21:06
 */

@Data
public class R<T> {
    Integer code;
    String msg;
    T data;


    R() {
        this.code = 200;
        this.msg = "成功";
    }

    public static <T> R<T> success(T data) {
        R<T> r = new R<>();
        r.data = data;
        return r;
    }

    public static <T> R<T> success(String msg,T data) {
        R<T> r = new R<>();
        r.data = data;
        r.msg = msg;
        return r;
    }

    public static <T> R<T> success() {
        return new R<>();
    }

    public static <T> R<T> error() {
        R<T> r = new R<>();
        r.code = 404;
        r.msg = "失败";
        return r;
    }

    public static <T> R<T> error(String msg) {
        R<T> r = new R<>();
        r.code = 404;
        r.msg = msg;
        return r;
    }
}
